package com.linln.modules.message.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.linln.common.enums.DayEnum;
import com.linln.common.enums.StatusEnum;
import com.linln.common.utils.StatusUtil;
import com.linln.modules.member.domain.MemberInfo;

import lombok.Data;

/**
 * @author hct
 * @date 2019/09/12
 */
@Data
@Entity
@Table(name="messageinfo")
@EntityListeners(AuditingEntityListener.class)
@Where(clause = StatusUtil.NOT_DELETE)
public class MessageInfo implements Serializable {
    // 主键ID
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Long id;
    private String area;
    @Transient
    private String areaname;
    // 所属城市
    private String city;
    // 所属大类
   // private Integer messageType1;
    
    //@Transient
    @ManyToOne(fetch=FetchType.LAZY)
    @NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="message_type1")   
    private MessageType typeone;
    // 所属小类
   // private Integer messageType2;
    //@Transient
    @ManyToOne(fetch=FetchType.LAZY)
    @NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="message_type2")   
    private MessageType typetwo;
    
    // 顺序
    private Integer num;
    // 发布时间
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date pushTime;
    // 创建时间
    @CreatedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createDate;
    // 更新时间
    @LastModifiedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateDate;
    
    // 发布人
    // private Long memberId;
    
  //  @Transient
    @ManyToOne(fetch=FetchType.LAZY)
    @NotFound(action=NotFoundAction.IGNORE)
    @JoinColumn(name="member_id")
    private MemberInfo member;
    
    // 联系人
    private String pushName;
    
    // 联系电话
    private String pushPhone;
    
    // 标题   当为顺风车时候 本字段存储 出发地-》目的地信息
    private String title;   
    
    // 描述   当为顺风车的时候本字段存储出发时间字段
    private String details;
    
    // 发布地址 当为顺风车的时候本字段存储人数
    private String address;
 
    // 内容 //json串
    private String content;
    
    private String logo;
    
    //多张图片
    private String imgs;
        
   // 备注
    private String remark;
        
    // 是否置顶
    private Integer istop;
    
    
    // 期限选择        1=7天/2=半个月/3个月/4=1季度/5=半年/6=1年
    private Integer day;
    
    private Integer dayCount;
    //广告时长内容
    @Transient
    private String dayValue;
    
    public String getDayValue() {
		return DayEnum.getVal(day); 
	}
    //开始时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
   	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date startTime;
    // 时长选择
    private Integer deadline;  //20分钟 /30分钟
    
    //结束时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
   	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date endTime;
    
    private String orderId;
    /**
     * 与orderid 相同
     */
    private String orderCode;
    //支付费用
    private Double fee;
 
    // 经度
    private String lat;
    // 纬度
    private String lng;
    
    // 转发数
    private Integer sharenum;
    
    private Integer readnum;
    
    private Integer collectnum;
    
    private Integer zannum;
    //支付状态  0是代付款待审核 1是已付款待审核  2 已拒绝已退款
    private Integer payStatus;    
    //0待审核 1已通过 2已拒绝
    private  Integer messageStatus;    
    //代理商信息
    private Long agentId;
    //代理商审核时间
    private Date shenheTime;
    
    // 状态
    private Byte status = StatusEnum.OK.getCode();
    @Transient
    private List<MemberInfo> memberInfos;
}